package com.lwx.setAndMap;

public class  LinkedListSet<T> implements Set<T> {
    //链表是线性结构，不需要其中的元素具有可比性
    private LinkedList<T> list;

    @Override
    public void add(T e) {
        if(!list.contains(e)){
            list.addFirst(e);
        }
    }

    @Override
    public void remove(T e) {
        list.removeElement(e);
    }

    @Override
    public boolean contains(T e) {
        return list.contains(e);
    }

    @Override
    public int getSize() {
        return list.getSize();
    }

    @Override
    public boolean isEmpty() {
        return list.isEmpty();
    }
}
